package com.sgb.contract.view.widget.pop;

import android.content.Context;

import androidx.databinding.ObservableField;

import com.sgb.contract.BR;
import com.sgb.contract.R;
import com.sgb.contract.utils.SimpleNotifyListener;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;

/**
 * 修改合同
 * @author cyj
 */
public class RejectContractPop extends BasePopWindow {

    /** 修改理由内容 */
    public ObservableField<String> rejectContractContent = new ObservableField<>("");
    private SimpleNotifyListener<String> listener;

    public RejectContractPop(Context context) {
        super(context, 5);
    }

    @Override
    protected int popLayout() {
        return R.layout.contract_include_reject_contract;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        holder.getmBinding().setVariable(BR.viewModel, this);
    }

    /**
     * 设置修改合同监听
     * @param listener
     */
    public void setRejectContractListener(SimpleNotifyListener<String> listener) {
        this.listener = listener;
    }

    /**
     * 取消
     */
    public void rejectContractCancelForOnclick() {
        dismiss();
    }

    /**
     * 修改合同
     */
    public void rejectContractSureForOnclick() {
        if(null != this.listener) {
            // 回调修改理由内容
            this.listener.notifyAny(rejectContractContent.get());
        }
        dismiss();
    }

    @Override
    public void dismiss() {
        rejectContractContent.set("");
        super.dismiss();
    }
}
